﻿using System;
using System.ComponentModel.Composition;
using Red.Controls.Shell;
using Red.Controls.ViewModels;

namespace Red.Toolkit.GeometryCutEditor
{
    [Export( typeof( IEditorInfo ) )]
    public class EditorInfo : IEditorInfo
    {
        public string Name
        {
            get { return "GeometryCutEditor"; }
        }

        public Type WindowClass
        {
            get { return typeof( GeometryCutEditor ); }
        }

        public Type SettingsClass
        {
            get { return typeof( UserSettings ); }
        }
    }

    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class GeometryCutEditor : RedEditorWindow
    {
        public GeometryCutEditor( IEditorHost host, EditorInstanceData instanceData, EditorSharedData sharedData )
            : base( host, instanceData, sharedData )
        {
            InitializeComponent();
        }

        private void RedMainWindow_Loaded( object sender, System.Windows.RoutedEventArgs e )
        {

        }

        private void RedEditorWindow_ContentRendered( object sender, EventArgs e )
        {
        }

        private async void AddElement_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            InstanceData.RootEditorItem.Execute( "addElement" );
            InteropDataItem elementsCenters = (InteropDataItem)await InstanceData.RootEditorItem.DigUpSubItemAsync("cookingContext.elementsCenters");
            await elementsCenters.RebuildAsync();
        }

        private async void RemoveElement_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            InstanceData.RootEditorItem.Execute( "removeElement", -1 );
            InteropDataItem elementsCenters = (InteropDataItem)await InstanceData.RootEditorItem.DigUpSubItemAsync("cookingContext.elementsCenters");
            await elementsCenters.RebuildAsync();
        }

        private void Shape0_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            InstanceData.RootEditorItem.Execute( "shape", 0 );
        }

        private void Shape1_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            InstanceData.RootEditorItem.Execute( "shape", 1 );
        }

        private void Shape2_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            InstanceData.RootEditorItem.Execute( "shape", 2 );
        }

        private void Shape3_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            InstanceData.RootEditorItem.Execute( "shape", 3 );
        }

        private void Shape4_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            InstanceData.RootEditorItem.Execute( "shape", 4 );
        }
        private void Shape5_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            InstanceData.RootEditorItem.Execute( "shape", 5 );
        }
    }
}
